package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

class zbj {
   int[] a;
   private zbk b;
   private int c;
   private int d;
   private int e;
   private int f;
   private int g;
   private Color h;
   private float i;
   private Color j;
   private boolean k;
   private boolean l;
   private float m = 0.0F;

   zbj(int var1, int var2, int var3, int var4, int var5, Color var6, float var7, Color var8, zbk var9) {
      this.c = var2;
      this.d = var3;
      this.e = var4;
      this.f = var5;
      this.g = var1;
      this.h = var6;
      this.i = var7;
      this.j = var8;
      this.b = var9;
      if (this.b != null) {
         if (var9.d != null) {
            this.a = (int[])com.aspose.cells.b.a.za.a(var9.d);
         }
      }
   }

   zbk a() {
      return this.b;
   }

   private int h() {
      int var1 = this.a().f;
      return (var1 & Integer.MIN_VALUE) != 0 && var1 < -1073741824 ? (int)this.a((short)(var1 & '\uffff'), (float)this.d(), this.e()) : var1;
   }

   private int i() {
      int var1 = this.a().g;
      return (var1 & Integer.MIN_VALUE) != 0 && var1 < -1073741824 ? (int)this.a((short)(var1 & '\uffff'), (float)this.d(), this.e()) : var1;
   }

   private com.aspose.cells.b.a.b.zo[] j() {
      com.aspose.cells.b.a.b.zn[] var1 = this.a().a;
      com.aspose.cells.b.a.b.zo[] var2 = new com.aspose.cells.b.a.b.zo[var1.length];
      float var3 = (float)this.d();
      float var4 = this.e();

      for(int var5 = 0; var5 < var1.length; ++var5) {
         com.aspose.cells.b.a.b.zn var6 = var1[var5];
         var2[var5] = new com.aspose.cells.b.a.b.zo((var6.a() & Integer.MIN_VALUE) != 0 && var6.a() < -1073741824 ? this.a((short)(var6.a() & '\uffff'), var3, var4) : (float)var6.a(), (var6.b() & Integer.MIN_VALUE) != 0 && var6.b() < -1073741824 ? this.a((short)(var6.b() & '\uffff'), var3, var4) : (float)var6.b());
      }

      return var2;
   }

   private float a(short var1, float var2, float var3) {
      byte var4 = 0;
      byte[] var5 = new byte[]{var4};
      float var6 = this.a().a(var1, this.a, var5);
      byte var8 = var5[0];
      float var7;
      if (var2 > var3) {
         var7 = var3 / var2;
         if ((var8 & 255 & 1) != 0) {
            if ((var8 & 255 & 2) == 0) {
               var6 *= var7;
            } else {
               var6 = (var6 - 10800.0F) * var7 + 10800.0F;
            }
         } else if ((var8 & 255 & 2) != 0) {
            var6 = (float)this.h() - ((float)this.h() - var6) * var7;
         }
      } else {
         var7 = var2 / var3;
         if ((var8 & 255 & 4) != 0) {
            if ((var8 & 255 & 8) == 0) {
               var6 *= var7;
            } else {
               var6 = (var6 - 10800.0F) * var7 + 10800.0F;
            }
         } else if ((var8 & 255 & 8) != 0) {
            var6 = (float)this.i() - ((float)this.i() - var6) * var7;
         }
      }

      return var6;
   }

   private com.aspose.cells.b.a.b.a.ze a(zbm[] var1, int[] var2, com.aspose.cells.b.a.b.zo[] var3, int[] var4, int[] var5, boolean[] var6, boolean[] var7) {
      var4[0] = 3;
      var5[0] = 1;
      var6[0] = false;
      var7[0] = true;
      com.aspose.cells.b.a.b.a.ze var8;
      if (var2 != null && var2.length != 0) {
         var8 = new com.aspose.cells.b.a.b.a.ze();
         int var9 = var1[0].a;
         boolean var10 = false;
         boolean var11 = false;
         boolean var12 = false;
         boolean var13 = false;
         boolean var14 = false;
         int var15 = var1[0].b;
         int var16 = var1[0].b;

         label217:
         for(int var17 = var1[0].b; var9 < var2.length; var15 = var16) {
            try {
               int var18 = var2[var9++];
               byte var19 = (byte)((var18 & '\uffff') >> 12);
               int var22;
               int var36;
               switch(var19) {
               case 0:
                  var22 = var18 & '\uffff' & 4095;
                  if (var10 || var8.e() == 0) {
                     ++var15;
                  }

                  var10 = false;
                  var16 = var15 + var22;

                  for(var36 = 0; var36 < var22; ++var36) {
                     var8.a(var3[var15 - 1], var3[var15]);
                     ++var15;
                  }
               case 1:
               case 3:
               case 5:
               case 7:
               case 9:
               default:
                  break;
               case 2:
                  var22 = var18 & '\uffff' & 4095;
                  if (var10 || var8.e() == 0) {
                     ++var15;
                  }

                  var10 = false;
                  var16 = var15 + var22 * 3;
                  var36 = 0;

                  while(true) {
                     if (var36 >= var22) {
                        continue label217;
                     }

                     var8.a(var3[var15 - 1], var3[var15], var3[var15 + 1], var3[var15 + 2]);
                     var15 += 3;
                     ++var36;
                  }
               case 4:
                  if (var10) {
                     ++var16;
                  }

                  var8.j();
                  var11 |= var12;
                  var12 = false;
                  var17 = var15;
                  var10 = true;
                  break;
               case 6:
                  var8.i();
                  var12 = true;
                  if (var8.e() > 0) {
                     var11 = true;
                  }
                  break;
               case 8:
                  com.aspose.cells.b.a.b.zo[] var23 = var8.c();
                  int var24 = var8.e();
                  if (var24 != 0) {
                     if (!var12 && var24 > 1 && com.aspose.cells.b.a.b.zo.a(var23[var24 - 1], var3[var17])) {
                        var12 = true;
                        var8.i();
                     }

                     boolean var10000 = var11 | var12;
                     if (!var13) {
                        switch(var18 & 65535 & 15) {
                        case 0:
                        default:
                           var4[0] = 3;
                           break;
                        case 1:
                           var4[0] = 2;
                           break;
                        case 2:
                           var4[0] = 4;
                           break;
                        case 3:
                           var4[0] = 0;
                           break;
                        case 4:
                           var4[0] = 3;
                           var6[0] = true;
                           break;
                        case 5:
                           var4[0] = 1;
                           break;
                        case 6:
                           var4[0] = 5;
                        }
                     } else {
                        var4[0] = 0;
                     }

                     if ((var18 & '\uffff' & 16) == 0 && !var14) {
                        var5[0] = (var18 & '\uffff' & 32) != 0 ? 2 : 1;
                     } else {
                        var5[0] = 0;
                     }

                     var7[0] = (var18 & '\uffff' & 256) == 0;
                     var1[0].b = var16;
                     var1[0].a = var9;
                     return var8;
                  }
                  break;
               case 10:
               case 11:
                  var22 = var18 & '\uffff' & 255;
                  byte var20 = (byte)((var18 & '\uffff' & 3840) >> 8);
                  com.aspose.cells.b.a.b.zo var26;
                  com.aspose.cells.b.a.b.zo var27;
                  float var29;
                  switch(var20) {
                  case 3:
                  case 4:
                  case 5:
                     if (var22 == 0) {
                        break;
                     }

                     var16 = var15 + var22;
                     if (var22 == 2) {
                        if (var10) {
                           ++var15;
                           ++var16;
                           var8.a(var3[var15 - 1], var3[var15 - 1]);
                        }

                        var10 = false;
                        var8.a(var3[var15].d(), var3[var15].e(), var3[var15 + 1].d() - var3[var15].d(), var3[var15 + 1].e() - var3[var15].e());
                        var15 += 2;
                        var12 = true;
                        break;
                     } else {
                        if (var22 % 4 != 0) {
                           throw new Exception("Invalid data autoshape segment" + Integer.toString(var18));
                        }

                        if (var10) {
                           ++var15;
                           ++var16;
                           var8.a(var3[var15 - 1], var3[var15 - 1]);
                        }

                        var10 = false;

                        while(true) {
                           if (var22 <= 0) {
                              continue label217;
                           }

                           com.aspose.cells.b.a.b.zq var25 = new com.aspose.cells.b.a.b.zq(var3[var15].d(), var3[var15].e(), var3[var15 + 1].d() - var3[var15].d(), var3[var15 + 1].e() - var3[var15].e());
                           var26 = var3[var15 + 2];
                           var27 = var3[var15 + 3];
                           com.aspose.cells.b.a.b.zo var28 = new com.aspose.cells.b.a.b.zo(var25.j() + var25.h() / 2.0F, var25.k() + var25.i() / 2.0F);
                           var29 = var26.d() - var28.d();
                           float var30 = var26.e() - var28.e();
                           float var31 = a(var29, var30);
                           var29 = var27.d() - var28.d();
                           var30 = var27.e() - var28.e();
                           float var32 = a(var29, var30);
                           float var34 = var32 - var31;
                           if (var34 < 0.0F) {
                              var34 += 360.0F;
                           }

                           if (var20 != 5) {
                              var34 -= 360.0F;
                           }

                           var8.a(var25, var31, var34);
                           var15 += 4;
                           var22 -= 4;
                        }
                     }
                  case 6:
                  case 7:
                  case 8:
                  case 9:
                  default:
                     if (var22 == 0) {
                        break;
                     }

                     if (var10 || var8.e() == 0) {
                        ++var15;
                     }

                     var10 = false;
                     var16 = var15 + var22;
                     boolean var21 = Math.signum(var3[var15].d() - var3[var15 - 1].d()) == Math.signum(var3[var15].e() - var3[var15 - 1].e());
                     int var37 = 0;

                     while(true) {
                        if (var37 >= var22) {
                           continue label217;
                        }

                        var26 = var3[var15 - 1];
                        var27 = var3[var15];
                        float var38 = var27.d() - var26.d();
                        var29 = var27.e() - var26.e();
                        boolean var39 = var21 != (Math.signum(var38) == Math.signum(var29));
                        if (var20 == 7) {
                           var39 = !var39;
                        }

                        if (var39) {
                           var8.a(var26, new com.aspose.cells.b.a.b.zo(var26.d() + var38 / 2.0F, var26.e()), new com.aspose.cells.b.a.b.zo(var27.d(), var27.e() - var29 / 2.0F), var27);
                        } else {
                           var8.a(var26, new com.aspose.cells.b.a.b.zo(var26.d(), var26.e() + var29 / 2.0F), new com.aspose.cells.b.a.b.zo(var27.d() - var38 / 2.0F, var27.e()), var27);
                        }

                        ++var37;
                        ++var15;
                     }
                  case 10:
                     var13 = true;
                     break;
                  case 11:
                     var14 = true;
                  }
               }
            } catch (Exception var35) {
               ;
            }
         }

         if (var8.e() > 0) {
            var4[0] = var11 ? 3 : 0;
            var1[0].b = var3.length;
            var1[0].a = var2.length;
            return var8;
         } else {
            return null;
         }
      } else if (var3 != null && var3.length != 0 && var1[0].a == 0) {
         var8 = new com.aspose.cells.b.a.b.a.ze();
         var8.a(var3);
         var8.i();
         var1[0].a = 1;
         var1[0].b = var3.length;
         return var8;
      } else {
         return null;
      }
   }

   void a(zn var1, zbkq var2, com.aspose.cells.b.a.b.zq var3) {
      com.aspose.cells.b.a.b.a.zf var4 = var1.e();
      var1.a(2);
      new com.aspose.cells.b.a.b.zm(this.h, this.i);
      com.aspose.cells.b.a.b.zm var6 = new com.aspose.cells.b.a.b.zm(this.h, this.i);
      var6.c(0);
      var6.d(0);
      new com.aspose.cells.b.a.b.zu(this.j);
      new com.aspose.cells.b.a.b.zu(Color.fromArgb(this.j.getA() & 255, (int)((double)(this.j.getR() & 255) * 0.8D + 0.5D), (int)((double)(this.j.getG() & 255) * 0.8D + 0.5D), (int)((double)(this.j.getB() & 255) * 0.8D + 0.5D)));
      new com.aspose.cells.b.a.b.zu(Color.fromArgb(this.j.getA() & 255, 255 - (int)((double)(255 - (this.j.getR() & 255)) * 0.8D + 0.5D), 255 - (int)((double)(255 - (this.j.getG() & 255)) * 0.8D + 0.5D), 255 - (int)((double)(255 - (this.j.getB() & 255)) * 0.8D + 0.5D)));
      new com.aspose.cells.b.a.b.zu(Color.fromArgb(this.j.getA() & 255, (int)((double)(this.j.getR() & 255) * 0.6D + 0.5D), (int)((double)(this.j.getG() & 255) * 0.6D + 0.5D), (int)((double)(this.j.getB() & 255) * 0.6D + 0.5D)));
      new com.aspose.cells.b.a.b.zu(Color.fromArgb(this.j.getA() & 255, 255 - (int)((double)(255 - (this.j.getR() & 255)) * 0.6D + 0.5D), 255 - (int)((double)(255 - (this.j.getG() & 255)) * 0.6D + 0.5D), 255 - (int)((double)(255 - (this.j.getB() & 255)) * 0.6D + 0.5D)));

      try {
         int[] var12 = this.a().b;
         float var13 = (float)this.h();
         float var14 = (float)this.i();
         com.aspose.cells.b.a.b.a.zi var15 = new com.aspose.cells.b.a.b.a.zi();
         var15.b(this.f(), this.g(), 0);
         var15.a((float)this.d() / var13, this.e() / var14, 0);
         com.aspose.cells.b.a.b.zo[] var16 = this.j();
         if (this.b() == 19) {
            this.a(var16);
         }

         var15.a(var16);
         ArrayList var17 = new ArrayList();
         zbm var18 = new zbm(0);

         while(true) {
            byte var19 = 0;
            byte var20 = 0;
            boolean var21 = false;
            boolean var22 = false;
            zbm[] var23 = new zbm[]{var18};
            int[] var24 = new int[]{var19};
            int[] var25 = new int[]{var20};
            boolean[] var26 = new boolean[]{var21};
            boolean[] var27 = new boolean[]{var22};
            com.aspose.cells.b.a.b.a.ze var28 = this.a(var23, var12, var16, var24, var25, var26, var27);
            var18 = var23[0];
            int var36 = var24[0];
            int var38 = var25[0];
            var21 = var26[0];
            var22 = var27[0];
            if (var28 == null) {
               Iterator var37 = var17.iterator();

               zbl var39;
               while(var37.hasNext()) {
                  var39 = (zbl)var37.next();
                  if (var39.b != null) {
                     var1.a(var39.b, var39.a);
                  }
               }

               var37 = var17.iterator();

               while(var37.hasNext()) {
                  var39 = (zbl)var37.next();
                  if (var39.c != null) {
                     var1.a(var39.c, var39.a);
                  }
               }
               break;
            }

            com.aspose.cells.b.a.b.zc var29 = null;
            if (!this.j.isEmpty()) {
               switch(var36) {
               case 0:
                  break;
               case 1:
                  var29 = zbul.a(var2.l(), var28);
                  break;
               case 2:
                  var29 = zbul.a(var2.l(), var28);
                  break;
               case 3:
               default:
                  var29 = zbul.a(var2.l(), var28);
                  break;
               case 4:
                  var29 = zbul.a(var2.l(), var28);
                  break;
               case 5:
                  var29 = zbul.a(var2.l(), var28);
               }
            }

            com.aspose.cells.b.a.b.zm var30 = null;
            if (!this.h.isEmpty()) {
               switch(var38) {
               case 0:
                  break;
               case 1:
               default:
                  var30 = zbul.a(var2.m());
                  break;
               case 2:
                  var30 = var6;
               }
            }

            com.aspose.cells.b.a.a.ze.a(var17, (Object)(new zbl(var28, var29, var30, var22)));
         }
      } catch (Exception var34) {
         ;
      } finally {
         var1.a(var4);
      }

   }

   public int b() {
      return this.g;
   }

   zai c() {
      return this.a != null ? new zai(this) : null;
   }

   private static float a(float var0, float var1) {
      float var2 = (float)zanc.b(Math.atan2((double)var1, (double)var0));
      if (var2 < 0.0F) {
         var2 += 360.0F;
      }

      return var2;
   }

   private void a(com.aspose.cells.b.a.b.zo[] var1) {
      float var2 = (float)(this.c().a(0) / 65536 % 360);
      float var3 = (float)(this.c().a(1) / 65536 % 360);
      if (var2 < 0.0F) {
         var2 += 360.0F;
      }

      if (var3 < 0.0F) {
         var3 += 360.0F;
      }

      float var4;
      float var5;
      float var6;
      float var7;
      if (var2 < var3) {
         var4 = var2 < 270.0F && var3 > 270.0F ? var1[0].e() : Math.min(var1[2].e(), var1[3].e());
         var5 = var2 < 180.0F && var3 > 180.0F ? var1[0].d() : Math.min(var1[2].d(), var1[3].d());
         var6 = var2 < 90.0F && var3 > 90.0F ? var1[1].e() : Math.max(var1[2].e(), var1[3].e());
         var7 = Math.max(var1[2].d(), var1[3].d());
      } else {
         var4 = var2 >= 270.0F && var3 <= 270.0F ? Math.min(var1[2].e(), var1[3].e()) : var1[0].e();
         var5 = var2 >= 180.0F && var3 <= 180.0F ? Math.min(var1[2].d(), var1[3].d()) : var1[0].d();
         var6 = var2 >= 90.0F && var3 <= 90.0F ? Math.max(var1[2].e(), var1[3].e()) : var1[1].e();
         var7 = var1[1].d();
      }

      var4 = Math.min(var4, 10800.0F);
      var5 = Math.min(var5, 10800.0F);
      var6 = Math.max(var6, 10800.0F);
      var7 = Math.max(var7, 10800.0F);
      float var8 = var7 - var5;
      float var9 = var6 - var4;
      float var10 = var1[1].d();
      float var11 = var1[1].e();
      if (var9 >= 1.0F && var8 >= 1.0F) {
         for(int var12 = 0; var12 < var1.length; ++var12) {
            var1[var12].a((var1[var12].d() - var5) / var8 * var10);
            var1[var12].b((var1[var12].e() - var4) / var9 * var11);
         }

      }
   }

   public int d() {
      return this.e;
   }

   public float e() {
      return (float)this.f;
   }

   public float f() {
      return (float)this.c;
   }

   public float g() {
      return (float)this.d;
   }

   public void a(boolean var1) {
      this.l = var1;
   }

   public void b(boolean var1) {
      this.k = var1;
   }

   public void a(float var1) {
      this.m = var1;
   }
}
